package com.bensonbasement.snorflux.utils;

import com.bensonbasement.snorflux.server.world.Space;

public class SpaceReference implements Reference<Space> {
	
	private final Coords coords;
	// TODO: Use a level reference instead of a level number?
	private final int levelNum;
//	private int levelNum;
	
	public SpaceReference(Coords coords, int levelNum) {
		this.coords = coords;
		this.levelNum = levelNum;
	}

	public Coords getCoords() {
		return coords;
	}
	
	public int getLevel() {
		return levelNum;
	}
	
//	public Level getLevel() {
//		return levelReference.dereference();
//	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof SpaceReference) {
			SpaceReference other = (SpaceReference) obj;
			return this.coords.equals(other.coords) && this.levelNum == other.levelNum;
		}
		else {
			return false;
		}
	}
	
	@Override
	public int hashCode() {
		// TODO: Implement a real hash code.
		return (""+coords+levelNum).hashCode();
	}
}
